<template>
    <a-layout-header :class="['header2', currentBackgroundClass]">
        <div class="navbar">
          <div class="navbar-left">
            <img class="logo" src="@/assets/logo.svg" alt="Logo" />
            <div class="logo-typeface">
              {{ $t("Research And Development platform") }}
            </div>
          </div>
          <div class="navbar-right">

            <div>
              <a-button @click="toggleLanguage">
                <icon-language size="19">切换语言 </icon-language>
              </a-button>
            </div>

            <div v-if="this.isDarkBackground === true">
              <a-button @click="toggleBackgroundColor">
                <icon-sun-fill size="19">切换</icon-sun-fill>
              </a-button>
            </div>
            <div v-else>
              <a-button @click="toggleBackgroundColor">
                <icon-moon-fill size="19">切换</icon-moon-fill>
              </a-button>
            </div>

            <a-button type="primary">{{
              $t("console.dashboard.login")
            }}</a-button>
            
          </div>
        </div>
      </a-layout-header>
</template>

<script>
import { defineComponent, ref } from "vue";
import { Message } from "@arco-design/web-vue";
import { IconHome, IconCalendar } from "@arco-design/web-vue/es/icon";

export default defineComponent({
  components: {
    IconHome,
    IconCalendar,
  },
  computed: {
    // 计算属性，根据 isDarkBackground 的值返回相应的 class 名称
    currentBackgroundClass() {
      // 如果 isDarkBackground 为 true 返回 'dark-background'，否则返回 'light-background'
      //  this.isDarkBackground ? 'dark-background' : 'light-background'
      return this.isDarkBackground
        ? document.body.setAttribute("arco-theme", "dark") || "dark-background"
        : document.body.removeAttribute("arco-theme") || "light-background";
    },
  },
  setup() {
    const collapsed = ref(false);
    const onCollapse = (val, type) => {
      const content = type === "responsive" ? "触发响应式收缩" : "点击触发收缩";
      Message.info({
        content,
        duration: 2000,
      });
      collapsed.value = val;
    };
    return {
      collapsed,
      onCollapse,
      onClickMenuItem(key) {
        Message.info({ content: `You select ${key}`, showIcon: true });
      },
    };
  },
  methods: {
    // 定义 toggleBackgroundColor 方法，用于切换 isDarkBackground 的值
    toggleBackgroundColor() {
      // 取反当前的 isDarkBackground 值
      this.isDarkBackground = !this.isDarkBackground;
    },
    toggleLanguage() {
      this.$i18n.locale = this.$i18n.locale === "zh-CN" ? "en-US" : "zh-CN";
    },
  },
  data() {
    return {
      // 定义 isDarkBackground 状态变量，初始值为 true
      isDarkBackground: true,
    };
  },
});

// document.body.removeAttribute('arco-theme')
// document.body.setAttribute('arco-theme', 'dark')

// 设置全局样式变量
// document.documentElement.style.setProperty('--primary-color', '#1890ff') // 调整主色调
// document.documentElement.style.setProperty('--text-color', '#004D1C'); // 设置文本颜色
// document.documentElement.style.setProperty('--background-color', '#141414') // 设置背景颜色
</script>
<style scoped>
.header2 {
  height: 930px;
  /* color: white; */
  background: var(--color-fill-1);
  /* border: 1px solid var(--color-border);   */
}
.header2 :deep(.arco-layout-sider) .logo {
  height: 32px;
  margin: 12px 8px;
  /* background: rgba(255, 255, 255, 0.2); */
}
.header2 :deep(.arco-layout-sider-light) .logo {
  /* background: var(--color-fill-2); */
}
.header2 :deep(.arco-layout-header) {
  height: 64px;
  line-height: 64px;
  /* background: var(--color-bg-3); */
}
.header2 :deep(.arco-layout-footer) {
  height: 48px;
  /* color: var(--color-text-2); */
  font-weight: 400;
  font-size: 14px;
  line-height: 48px;
  /* background-color: brown; */
}
.header2 :deep(.arco-layout-content) {
  /* color: var(--color-text-2); */
  font-weight: 400;
  font-size: 14px;
  /* background: var(--color-bg-1); */
}
.header2 :deep(.arco-layout-footer),
.header2 :deep(.arco-layout-content) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* color: var(--color-white); */
  font-size: 16px;
  font-stretch: condensed;
  text-align: center;
}


/* 定义基础的 header 样式 */
.header2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: 45px; /* 增加高度 */
  transition: background; /* 添加过渡效果 */
  /* transition: background 0.3s ease; */
}

/* 定义深色背景的样式 */
.dark-background {
  color: white;
  background-color: #000000;
}

/* 定义浅色背景的样式 */
.light-background {
  color: #000000;
}

/* 定义导航栏的样式 */
.navbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 定义左侧导航栏的样式 */
.navbar-left {
  display: flex;
  align-items: center;
}

/* 定义 logo 图片的样式 */
.logo {
  height: 5%;
}

/* 定义 logo 文字的样式 */
.logo-typeface {
  height: 5%;
}

/* 定义右侧导航栏的样式 */
.navbar-right {
  display: flex;
  align-items: center;
}
</style>
